brute force greedy implementation *1300

Please click on ads to support us..

C++ Code:

#include<bits/stdc++.h>
using namespace std;
typedef    long long int   ll;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
ll test,h,p,i,j,s,xy,n,flag=0,u,count,d,o1=0,o2=0,e,l,r,x,y,m,z,max1,x1,y1,k,x2,y2,z1,z2,sum,min1;
cin>>n;
vector<ll>a(n);
map<ll,ll>mk;
for(i=0;i<n;i++){
    cin>>a[i];
    mk[a[i]]++;
}
sum=0;
for(i=0;i<n;i++){
    mk[a[i]]--;
    flag=1;
    for(j=0;j<32;j++){
        if(mk[pow(2,j)-a[i]]>=1){
            flag=0;
        }
    }
    mk[a[i]]++;
    sum+=flag;
}
cout<<sum<<"\n";
return 0;
}


Comments

Submit
0 Comments
More Questions

137C - History
1443C - The Delivery Dilemma
6C - Alice Bob and Chocolate
1077C - Good Array
285B - Find Marble
6A - Triangle
1729A - Two Elevators
1729B - Decode String
1729C - Jumping on Tiles
1729E - Guess the Cycle Size
553B - Kyoya and Permutation
1729D - Friends and the Restaurant
1606C - Banknotes
580C - Kefa and Park
342A - Xenia and Divisors
1033A - King Escape
39D - Cubical Planet
1453A - Cancel the Trains
645A - Amity Assessment
1144A - Diverse Strings
1553B - Reverse String
1073A - Diverse Substring
630N - Forecast
312B - Archer
34D - Road Map
630I - Parking Lot
160B - Unlucky Ticket
371B - Fox Dividing Cheese
584B - Kolya and Tanya
137B - Permutation